<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div id="show"> </div>
  <script>
    var show = document.getElementById("show");

    var endDate = new Date("2021-2-11"); //春节

    function daojishi() {
      var date = new Date();//当前时间
      var diff = Math.floor((endDate.getTime() - date.getTime()) / 1000); //系统时间 到春节毫秒数差
      console.log(diff) //8672422  
      var second = diff % 60;  //秒数
      var minutes = Math.floor(diff / 60 % 60);//分钟
      var hours = Math.floor(diff / 60 / 60 % 24);// 小时
      var day = Math.floor(diff / 60 / 60 / 24) //天数
      show.innerHTML = `距离春节还有：${day}天,${hours}小时,${minutes}分钟,${second}秒`
    }
    setInterval(daojishi, 1000)

  </script>
</body>

</html>